package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbSellerMapper;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.pojo.TbSellerExample;
import com.dongdongshop.service.TbSellerServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class TbSellerServiceImpl implements TbSellerServiceI {

    @Autowired
    private TbSellerMapper tbSellerMapper;

    @Override
    @Transactional
    public List<TbSeller> getFindAll(String name,String nickName) {
        return tbSellerMapper.getFindAll(name,nickName);
    }

    @Override
    @Transactional
    public TbSeller detailsQquery(String id) {
        return  tbSellerMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void updateTbSeller(TbSeller tbSeller) {
        tbSellerMapper.updateByPrimaryKeySelective(tbSeller);
    }

    @Override
    public void deleteTbSeller(String id) {
        tbSellerMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void saveTbSeller(TbSeller tbSeller) {
        tbSeller.setCreateTime(new Date());
        tbSeller.setStatus("0");
        tbSellerMapper.insertSelective(tbSeller);
    }

    @Override
    public TbSeller listGet(String username) {
        TbSellerExample example = new TbSellerExample();
        TbSellerExample.Criteria criteria = example.createCriteria();
        criteria.andSellerIdEqualTo(username);
        List<TbSeller> list = tbSellerMapper.selectByExample(example);
        return (list == null || list.size() <= 0) ? null : list.get(0);
    }
}
